﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeroAnimations : MonoBehaviour
{
    private Hero _hero;
    private Animator _animator;
    private SpriteRenderer _spriteRenderer;

    public float Damage { get; set; }

    private void PlayTowardsAnimation()
    {
        _animator.SetInteger("Towards",_hero.GetHeroTowards);
    }

    private void IsTurningXAttack()
    {
        if ((_hero.CurrentMonsterTarget != null) && (_hero.transform.position.x - _hero.CurrentMonsterTarget.transform.position.x < 0))
        {
            _spriteRenderer.flipX = false;
        }
        else
        {
            _spriteRenderer.flipX = true;
        }
    }

    // Start is called before the first frame update
    private void Start()
    {
        _hero = GetComponent<Hero>();
        _animator = GetComponent<Animator>();
        _spriteRenderer = GetComponent<SpriteRenderer>();
    }

    // Update is called once per frame
    private void Update()
    {
        IsTurningXAttack();
        PlayTowardsAnimation();
    }
}
